int LEDPin = 9;
int inputPin = A0;
//初始化输出脚
//初始化输入脚
void setup()
{
   Serial.begin(9600);//串口初始化
   pinMode(LEDPin,OUTPUT);
   pinMode(inputPin,INPUT); 
}

void loop()
{
   int reading = analogRead(inputPin);
   //读取电位器的电压模拟数据
   int LEDState = map(reading,0,1023,0,255); 
   //适当放缩成analogWrite函数能够支持的范围
   analogWrite(LEDPin,LEDState);
   //用analogWrite函数输出
   Serial.print("The LEDState is ");
   Serial.println(LEDState);
   //串口输出产看模拟数据后放缩的成果
   delay(30);
   
}
